<!-- HTML header for doxygen 1.8.20-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=9"/>
	<meta name="generator" content="Doxygen 1.9.4"/>
	<meta name="viewport" content="width=device-width, initial-scale=1"/>
	<title>Raspberry Pi Pico SDK: include/pico/sem.h Source File</title>
	<!-- <link href="tabs.css" rel="stylesheet" type="text/css"/> -->
	<script type="text/javascript" src="jquery.js"></script>
	<script type="text/javascript" src="dynsections.js"></script>
	<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
	<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
	<link href="doxygen.css" rel="stylesheet" type="text/css" />
	<link href="normalise.css" rel="stylesheet" type="text/css"/>
<link href="main.css" rel="stylesheet" type="text/css"/>
<link href="styles.css" rel="stylesheet" type="text/css"/>
</head>
<body>
	<div class="navigation-mobile">
		<div class="logo--mobile">
			<a href="/"><img src="logo-mobile.svg" alt="Raspberry Pi"></a>
		</div>
		<div class="navigation-toggle">
			<span class="line-1"></span>
			<span class="line-2">
				<p>Menu Toggle</p>
			</span>
			<span class="line-3"></span>
		</div>
	</div>
	<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
		<div class="logo">
			<a href="index.html"> <img src="logo.svg" alt="Raspberry Pi"></a>
			<span style="display: inline-block; margin-top: 10px;">
				v2.1.0
			</span>
		</div>
		<div class="navigation-footer">
			<img src="logo-mobile.svg" alt="Raspberry Pi">
			<a href="https://www.raspberrypi.com/" target="_blank">By Raspberry Pi Ltd</a>
		</div>
<!-- 		<div class="search">
			<form>
				<input type="search" name="search" id="search" placeholder="Search">
				<input type="submit" value="Search">
			</form>
		</div> -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('sem_8h_source.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle"><div class="title">sem.h</div></div>
</div><!--header-->
<div class="contents">
<a href="sem_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span><span class="comment">/*</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno">    2</span><span class="comment"> * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.</span></div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno">    3</span><span class="comment"> *</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno">    4</span><span class="comment"> * SPDX-License-Identifier: BSD-3-Clause</span></div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno">    5</span><span class="comment"> */</span></div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno">    6</span> </div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno">    7</span><span class="preprocessor">#ifndef _PICO_SEM_H</span></div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno">    8</span><span class="preprocessor">#define _PICO_SEM_H</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno">    9</span> </div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno">   10</span><span class="preprocessor">#include &quot;<a class="code" href="lock__core_8h.html">pico/lock_core.h</a>&quot;</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno">   11</span> </div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno">   28</span><span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno">   29</span><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {</div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno">   30</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"><a class="line" href="structsemaphore.html">   31</a></span><span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code hl_struct" href="structsemaphore.html">semaphore</a> {</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno">   32</span>    <span class="keyword">struct </span><a class="code hl_struct" href="structlock__core.html">lock_core</a> core;</div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno">   33</span>    int16_t permits;</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno">   34</span>    int16_t max_permits;</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno">   35</span>} <a class="code hl_struct" href="structsemaphore.html">semaphore_t</a>;</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno">   36</span> </div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno">   37</span> </div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno">   45</span><span class="keywordtype">void</span> <a class="code hl_function" href="group__sem.html#gab4e56b5ccfacafd2fb17765e702a21ba">sem_init</a>(<a class="code hl_struct" href="structsemaphore.html">semaphore_t</a> *sem, int16_t initial_permits, int16_t max_permits);</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno">   46</span> </div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"><a class="line" href="group__sem.html#gad9e065ef0c0e59309f9bdb5fb74bb7c1">   53</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="group__sem.html#gad9e065ef0c0e59309f9bdb5fb74bb7c1">sem_available</a>(<a class="code hl_struct" href="structsemaphore.html">semaphore_t</a> *sem);</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno">   54</span> </div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"><a class="line" href="group__sem.html#gaeac89066f5fdbde0c7db2718464dcbde">   64</a></span><span class="keywordtype">bool</span> <a class="code hl_function" href="group__sem.html#gaeac89066f5fdbde0c7db2718464dcbde">sem_release</a>(<a class="code hl_struct" href="structsemaphore.html">semaphore_t</a> *sem);</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno">   65</span> </div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"><a class="line" href="group__sem.html#gab6c128952e4981a95ce2e2d093a8a3ba">   74</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="group__sem.html#gab6c128952e4981a95ce2e2d093a8a3ba">sem_reset</a>(<a class="code hl_struct" href="structsemaphore.html">semaphore_t</a> *sem, int16_t permits);</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno">   75</span> </div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"><a class="line" href="group__sem.html#gaefa22667355703497ae883f68a87aacf">   83</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="group__sem.html#gaefa22667355703497ae883f68a87aacf">sem_acquire_blocking</a>(<a class="code hl_struct" href="structsemaphore.html">semaphore_t</a> *sem);</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno">   84</span> </div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"><a class="line" href="group__sem.html#ga38275bfc4c00e5039028f58860709610">   96</a></span><span class="keywordtype">bool</span> <a class="code hl_function" href="group__sem.html#ga38275bfc4c00e5039028f58860709610">sem_acquire_timeout_ms</a>(<a class="code hl_struct" href="structsemaphore.html">semaphore_t</a> *sem, uint32_t timeout_ms);</div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno">   97</span> </div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"><a class="line" href="group__sem.html#ga0f5a509fb132e8e764795a66773500ad">  109</a></span><span class="keywordtype">bool</span> <a class="code hl_function" href="group__sem.html#ga0f5a509fb132e8e764795a66773500ad">sem_acquire_timeout_us</a>(<a class="code hl_struct" href="structsemaphore.html">semaphore_t</a> *sem, uint32_t timeout_us);</div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno">  110</span> </div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"><a class="line" href="group__sem.html#ga4410f17fc2f35b91e5bcfaf18bcf26ae">  123</a></span><span class="keywordtype">bool</span> <a class="code hl_function" href="group__sem.html#ga4410f17fc2f35b91e5bcfaf18bcf26ae">sem_acquire_block_until</a>(<a class="code hl_struct" href="structsemaphore.html">semaphore_t</a> *sem, <a class="code hl_typedef" href="group__timestamp.html#ga8b7f3d602cc053f05bacceeacc257ed8">absolute_time_t</a> until);</div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno">  124</span> </div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"><a class="line" href="group__sem.html#ga25b473ab6f287e4a6a0c9d0288a0a497">  134</a></span><span class="keywordtype">bool</span> <a class="code hl_function" href="group__sem.html#ga25b473ab6f287e4a6a0c9d0288a0a497">sem_try_acquire</a>(<a class="code hl_struct" href="structsemaphore.html">semaphore_t</a> *sem);</div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno">  135</span> </div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno">  136</span><span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno">  137</span>}</div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno">  138</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno">  139</span><span class="preprocessor">#endif</span></div>
<div class="ttc" id="agroup__sem_html_ga0f5a509fb132e8e764795a66773500ad"><div class="ttname"><a href="group__sem.html#ga0f5a509fb132e8e764795a66773500ad">sem_acquire_timeout_us</a></div><div class="ttdeci">bool sem_acquire_timeout_us(semaphore_t *sem, uint32_t timeout_us)</div><div class="ttdoc">Acquire a permit from a semaphore, with timeout.</div></div>
<div class="ttc" id="agroup__sem_html_ga25b473ab6f287e4a6a0c9d0288a0a497"><div class="ttname"><a href="group__sem.html#ga25b473ab6f287e4a6a0c9d0288a0a497">sem_try_acquire</a></div><div class="ttdeci">bool sem_try_acquire(semaphore_t *sem)</div><div class="ttdoc">Attempt to acquire a permit from a semaphore without blocking.</div></div>
<div class="ttc" id="agroup__sem_html_ga38275bfc4c00e5039028f58860709610"><div class="ttname"><a href="group__sem.html#ga38275bfc4c00e5039028f58860709610">sem_acquire_timeout_ms</a></div><div class="ttdeci">bool sem_acquire_timeout_ms(semaphore_t *sem, uint32_t timeout_ms)</div><div class="ttdoc">Acquire a permit from a semaphore, with timeout.</div></div>
<div class="ttc" id="agroup__sem_html_ga4410f17fc2f35b91e5bcfaf18bcf26ae"><div class="ttname"><a href="group__sem.html#ga4410f17fc2f35b91e5bcfaf18bcf26ae">sem_acquire_block_until</a></div><div class="ttdeci">bool sem_acquire_block_until(semaphore_t *sem, absolute_time_t until)</div><div class="ttdoc">Wait to acquire a permit from a semaphore until a specific time.</div></div>
<div class="ttc" id="agroup__sem_html_gab4e56b5ccfacafd2fb17765e702a21ba"><div class="ttname"><a href="group__sem.html#gab4e56b5ccfacafd2fb17765e702a21ba">sem_init</a></div><div class="ttdeci">void sem_init(semaphore_t *sem, int16_t initial_permits, int16_t max_permits)</div><div class="ttdoc">Initialise a semaphore structure.</div><div class="ttdef"><b>Definition:</b> sem.c:10</div></div>
<div class="ttc" id="agroup__sem_html_gab6c128952e4981a95ce2e2d093a8a3ba"><div class="ttname"><a href="group__sem.html#gab6c128952e4981a95ce2e2d093a8a3ba">sem_reset</a></div><div class="ttdeci">void sem_reset(semaphore_t *sem, int16_t permits)</div><div class="ttdoc">Reset semaphore to a specific number of available permits.</div></div>
<div class="ttc" id="agroup__sem_html_gad9e065ef0c0e59309f9bdb5fb74bb7c1"><div class="ttname"><a href="group__sem.html#gad9e065ef0c0e59309f9bdb5fb74bb7c1">sem_available</a></div><div class="ttdeci">int sem_available(semaphore_t *sem)</div><div class="ttdoc">Return number of available permits on the semaphore.</div></div>
<div class="ttc" id="agroup__sem_html_gaeac89066f5fdbde0c7db2718464dcbde"><div class="ttname"><a href="group__sem.html#gaeac89066f5fdbde0c7db2718464dcbde">sem_release</a></div><div class="ttdeci">bool sem_release(semaphore_t *sem)</div><div class="ttdoc">Release a permit on a semaphore.</div></div>
<div class="ttc" id="agroup__sem_html_gaefa22667355703497ae883f68a87aacf"><div class="ttname"><a href="group__sem.html#gaefa22667355703497ae883f68a87aacf">sem_acquire_blocking</a></div><div class="ttdeci">void sem_acquire_blocking(semaphore_t *sem)</div><div class="ttdoc">Acquire a permit from the semaphore.</div></div>
<div class="ttc" id="agroup__timestamp_html_ga8b7f3d602cc053f05bacceeacc257ed8"><div class="ttname"><a href="group__timestamp.html#ga8b7f3d602cc053f05bacceeacc257ed8">absolute_time_t</a></div><div class="ttdeci">uint64_t absolute_time_t</div><div class="ttdoc">An opaque 64 bit timestamp in microseconds.</div><div class="ttdef"><b>Definition:</b> types.h:43</div></div>
<div class="ttc" id="alock__core_8h_html"><div class="ttname"><a href="lock__core_8h.html">lock_core.h</a></div></div>
<div class="ttc" id="astructlock__core_html"><div class="ttname"><a href="structlock__core.html">lock_core</a></div><div class="ttdef"><b>Definition:</b> lock_core.h:53</div></div>
<div class="ttc" id="astructsemaphore_html"><div class="ttname"><a href="structsemaphore.html">semaphore</a></div><div class="ttdef"><b>Definition:</b> sem.h:31</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->

	<script src="main.js"></script>
</body>
</html>